package everydayGrade.t6;

import java.util.Arrays;

/**
 * @Author: Siantar
 * @Date: 2023-11-30-16:10
 * @Description: 1.0
 */
public class T1657 {
    public boolean closeStrings(String word1, String word2) {
        int[] cnt1 = new int[26];int[] cnt2 = new int[26];
        for (char c : word1.toCharArray()) cnt1[c - 'a']++;for (char c : word2.toCharArray()) cnt2[c - 'a']++;
        for (int i = 0; i < 26; i++)if (Math.max(cnt1[i], cnt2[i]) > 0 && Math.min(cnt1[i], cnt2[i]) == 0) return false;
        Arrays.sort(cnt1);Arrays.sort(cnt2);for (int i = 0; i < 26; i++) if (cnt1[i] != cnt2[i]) return false;
        return true;
    }
}
